package com.mouse.hxsj.service;

import com.mouse.damo.micro.*;
import com.mouse.haoi.service.CustomService;
import com.mouse.hxsj.constants.SystemParams;
import com.mouse.hxsj.util.DateUtil;
import com.mouse.hxsj.util.JsonUtil;

import java.util.Date;

public class Test {
    static CustomService customService = new CustomService();

    public static void main(String[] args) {
        Com com = new Com();
        FindStr findStr = new FindStr(com);
        Mouse mouse = new Mouse(com);
        FindPic findPic = new FindPic(com);
        com.setResourcePath("D:\\damo");
        com.setDict(0, "商店.txt");
        com.setDict(1, "价格.txt");
        com.setDict(2, "坐标.txt");
        int hwnd = 1836728;
        boolean bind = com.bind(hwnd);
        System.out.println("绑定窗口" + bind);
        // 查询窗口宽高
        Window window = new Window(com);
        int[] windowRect = window.getClientSize(hwnd);
        System.out.println("窗口宽高" + JsonUtil.toJson(windowRect));
        int height = windowRect[2], width = windowRect[1];
        int index=0;
        while (true) {
            index++;
            if(index%1000==0)System.out.println(index);
            Sleep.sleep(300);
            int[] pics = findStr.findStrE(0, 0, width, height, "上古妖魔",
                    "95e200-000000", 0.9, 2);
            if (pics[0] == -1) continue;
            File file = new File(com);
            String picName = SystemParams.sourcePath + "/地点/" + DateUtil.toDateStr(new Date(), "yyyy-MM-dd HH-mm-ss") + ".png";
            boolean imageFlag = file.screenImage(0, 0, width, height, picName);
            System.out.println(imageFlag);
            Sleep.sleep(5000);
        }


    }
}
